package org.onion.pattern.kit.validation.annotation;


import org.onion.pattern.kit.validation.annotation.validator.PropNameValidator;
import jakarta.validation.Constraint;
import jakarta.validation.Payload;

import java.lang.annotation.Documented;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * 中否是属性命名规则 【必须是字母开头，允许字母数字下划线】
 *
 */
@Documented
@Constraint(validatedBy = {PropNameValidator.class})
@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE})
@Retention(RUNTIME)
@Repeatable(IsPropName.PropNameList.class)
public @interface IsPropName {

    String message() default "必须是字母开头,字母数字下划线组成";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    @Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE})
    @Retention(RUNTIME)
    @Documented
    @interface PropNameList {
        IsPropName[] value();
    }

}
